package edu.csumb.itcd.teammario;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

public class ShotGunWeapon extends Weapon{
	   
	public ShotGunWeapon(int damage, int rateOfFire)
    {
		super(damage, rateOfFire);
		rateOfFire = 15;
    }
	 public void playerFire(Point start, Point destination)
	    {
	        //Rate of fire check ie: higher rateOfFire slower you shoot
	        if (Game.gameCount >= lastShotTime + rateOfFire)
	        {
	            lastShotTime = Game.gameCount;
	            
	            Point temp1, temp2;
	            if (destination.getX() - start.x < 100 && destination.getX() - start.x > -100){
	            	
	            	int adjustment = 0;
	            	
	            	if (destination.getX() - start.x < 3 && destination.getX() - start.x >= 3){
	            		
	            		if (destination.getY() - start.y < 3 && destination.getY() - start.y >= 3){
	            			
	            			adjustment = 100;
	            		}
	            	}
	            	temp1 = new Point((int)destination.getX() - 15, (int)destination.getY()+ adjustment);
	            	temp2 = new Point((int)destination.getX() + 15, (int)destination.getY()+ adjustment);
	            }
	            else {
	            	
	            	int adjustment = 0;
						            	
					if (destination.getX() - start.x < 3 && destination.getX() - start.x >= 3){
	            		
	            		if (destination.getY() - start.y < 3 && destination.getY() - start.y >= 3){
	            			
	            			adjustment = 100;
	            		}
	            	}
	            	temp1 = new Point((int)destination.getX() + adjustment, (int)destination.getY() - 15);
	            	temp2 = new Point((int)destination.getX() + adjustment, (int)destination.getY() + 15);
	            }
	            
	            Bullet bullet = new Bullet(start, destination, damage, range);
	            Bullet bullet1 = new Bullet(start, temp1, damage, range);
	            Bullet bullet2 = new Bullet(start, temp2, damage, range);
	            
	            BulletList.addPlayerBullet(bullet);
	            BulletList.addPlayerBullet(bullet1);
	            BulletList.addPlayerBullet(bullet2);
	        }
	    }
	    public void towerFire(Point start, Point2D destination)
	    {
	        //Rate of fire check ie: higher rateOfFire slower you shoot
	        if (Game.gameCount >= lastShotTime + rateOfFire)
	        {
	            lastShotTime = Game.gameCount;
	            Point temp1, temp2;
	            if (destination.getX() - start.x < 100 && destination.getX() - start.x > -100){
	            	
	            	int adjustment = 0;
	            	
	            	if (destination.getX() - start.x < 3 && destination.getX() - start.x >= 3){
	            		
	            		if (destination.getY() - start.y < 3 && destination.getY() - start.y >= 3){
	            			
	            			adjustment = 100;
	            		}
	            	}
	            	temp1 = new Point((int)destination.getX() - 15, (int)destination.getY()+ adjustment);
	            	temp2 = new Point((int)destination.getX() + 15, (int)destination.getY()+ adjustment);
	            }
	            else {
	            	
	            	int adjustment = 0;
						            	
					if (destination.getX() - start.x < 3 && destination.getX() - start.x >= 3){
	            		
	            		if (destination.getY() - start.y < 3 && destination.getY() - start.y >= 3){
	            			
	            			adjustment = 100;
	            		}
	            	}
	            	temp1 = new Point((int)destination.getX() + adjustment, (int)destination.getY() - 15);
	            	temp2 = new Point((int)destination.getX() + adjustment, (int)destination.getY() + 15);
	            }
	            Bullet bullet = new Bullet(start, destination, damage, range);
	            Bullet bullet1 = new Bullet(start, temp1, damage, range);
	            Bullet bullet2 = new Bullet(start, temp2, damage, range);
	            BulletList.addTowerBullet(bullet);
	            BulletList.addTowerBullet(bullet1);
	            BulletList.addTowerBullet(bullet2);
	        }
	    }
	    public void enemyFire(Point start, Point destination)
	    {
	        //Rate of fire check ie: higher rateOfFire slower you shoot
	        if (Game.gameCount >= lastShotTime + rateOfFire)
	        {
	            lastShotTime = Game.gameCount;
	            Point temp1, temp2;
	            if (destination.x - start.x < 100 && destination.x - start.x > -100){
	            	temp1 = new Point(destination.x - 15, destination.y);
	            	temp2 = new Point(destination.x + 15, destination.y);
	            }
	            else {
	            	temp1 = new Point(destination.x, destination.y - 15);
	            	temp2 = new Point(destination.x, destination.y + 15);
	            }
	            Bullet bullet = new Bullet(start, destination, damage, range);
	            Bullet bullet1 = new Bullet(start, temp1, damage, range);
	            Bullet bullet2 = new Bullet(start, temp2, damage, range);
	            BulletList.addEnemyBullet(bullet);
	            BulletList.addEnemyBullet(bullet1);
	            BulletList.addEnemyBullet(bullet2);
	        }
	    }
	    public String getWeaponName()
	    {
	    	return "Shot Gun Weapon";
	    }


}
